package utils

import (
	"crypto/md5"
	"encoding/hex"
	"fmt"
	"io"
	"os"
)

func MD5V(str []byte) string {
	h := md5.New()
	h.Write(str)
	return hex.EncodeToString(h.Sum(nil))
}

func GetFileMD5(filename string) string {
	hash := md5.New()
	file, _ := os.Open(filename)
	defer file.Close()
	io.Copy(hash, file)
	md5Hash := hash.Sum(nil)
	return fmt.Sprintf("%x", md5Hash)
}
